/*
 Copyright (C) 2010 Chris Hawkins. All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
 
 * Redistributions of source code must retain the above copyright notice, this
 list of conditions and the following disclaimer.
 
 * Neither the name of the author nor the names of its contributors may be used
 to endorse or promote products derived from this software without specific
 prior written permission.
 
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#import "AsdMacro.h"
#import "AsdParseDef.h"

stASDPrElement astASDPrElementBase[] = {
    { eASDPrElement_Attribute                 ,@"Attribute"                 },
    { eASDPrElement_BatchPutAttributesResponse,@"BatchPutAttributesResponse"},  // Put the single BatchPutAttributes element into base
    { eASDPrElement_BoxUsage                  ,@"BoxUsage"                  },
    { eASDPrElement_Code                      ,@"Code"                      },
    { eASDPrElement_DeleteAttributesResponse  ,@"DeleteAttributesResponse"  },  // Put the single DeleteAttributes element into base
    { eASDPrElement_Error                     ,@"Error"                     },
    { eASDPrElement_Errors                    ,@"Errors"                    },
    { eASDPrElement_Item                      ,@"Item"                      },
    { eASDPrElement_Message                   ,@"Message"                   },
    { eASDPrElement_Name                      ,@"Name"                      },
    { eASDPrElement_PutAttributesResponse     ,@"PutAttributesResponse"     },  // Put the single PutAttributes element into base
    { eASDPrElement_RequestId                 ,@"RequestId"                 },
    { eASDPrElement_RequestId                 ,@"RequestID"                 },  // A bit careless at AWS
    { eASDPrElement_Response                  ,@"Response"                  },
    { eASDPrElement_ResponseMetadata          ,@"ResponseMetadata"          },
    { eASDPrElement_Value                     ,@"Value"                     },
};
stASDPrElement astASDPrElementCreateDomain[] = {
    { eASDPrElement_CreateDomainResponse    ,@"CreateDomainResponse"    },
};
stASDPrElement astASDPrElementDeleteDomain[] = {
    { eASDPrElement_DeleteDomainResponse    ,@"DeleteDomainResponse"    },
};
stASDPrElement astASDPrElementDomainMetadata[] = {
    { eASDPrElement_DomainMetadataResponse  ,@"DomainMetadataResponse"  },
    { eASDPrElement_DomainMetadataResult    ,@"DomainMetadataResult"    },
    { eASDPrElement_AttributeNameCount      ,@"AttributeNameCount"      },
    { eASDPrElement_AttributeNamesSizeBytes ,@"AttributeNamesSizeBytes" },
    { eASDPrElement_AttributeValueCount     ,@"AttributeValueCount"     },
    { eASDPrElement_AttributeValuesSizeBytes,@"AttributeValuesSizeBytes"},
    { eASDPrElement_ItemCount               ,@"ItemCount"               },
    { eASDPrElement_ItemNamesSizeBytes      ,@"ItemNamesSizeBytes"      },
    { eASDPrElement_Timestamp               ,@"Timestamp"               },
};
stASDPrElement astASDPrElementListDomains[] = {
    { eASDPrElement_DomainName              ,@"DomainName"              },
    { eASDPrElement_ListDomainsMetadata     ,@"ListDomainsMetadata"     },
    { eASDPrElement_ListDomainsResponse     ,@"ListDomainsResponse"     },
    { eASDPrElement_ListDomainsResult       ,@"ListDomainsResult"       },
};
stASDPrElement astASDPrElementGetSelect[] = {
    { eASDPrElement_NextToken               ,@"NextToken"               },
    { eASDPrElement_GetAttributesResponse   ,@"GetAttributesResponse"   },
    { eASDPrElement_GetAttributesResult     ,@"GetAttributesResult"     },
    { eASDPrElement_SelectResponse          ,@"SelectResponse"          },
    { eASDPrElement_SelectResult            ,@"SelectResult"            },
};
stASDPrElement astASDPrAPIError[] = {
    { eASDPrAPIError_AccessFailure,                       @"AccessFailure"                        },
    { eASDPrAPIError_AttributeDoesNotExist,               @"AttributeDoesNotExist"                },
    { eASDPrAPIError_AuthFailure,                         @"AuthFailure"                          },
    { eASDPrAPIError_AuthMissingFailure,                  @"AuthMissingFailure"                   },
    { eASDPrAPIError_ConditionalCheckFailed,              @"ConditionalCheckFailed"               },
    { eASDPrAPIError_ExistsAndExpectedValue,              @"ExistsAndExpectedValue"               },
    { eASDPrAPIError_FeatureDeprecated,                   @"FeatureDeprecated"                    },
    { eASDPrAPIError_IncompleteExpectedExpression,        @"IncompleteExpectedExpression"         },
    { eASDPrAPIError_InternalError,                       @"InternalError"                        },
    { eASDPrAPIError_InvalidAction,                       @"InvalidAction"                        },
    { eASDPrAPIError_InvalidClientTokenId,                @"InvalidClientTokenId"                 },
    { eASDPrAPIError_InvalidHTTPAuthHeader,               @"InvalidHTTPAuthHeader"                },
    { eASDPrAPIError_InvalidHttpRequest,                  @"InvalidHttpRequest"                   },
    { eASDPrAPIError_InvalidLiteral,                      @"InvalidLiteral"                       },
    { eASDPrAPIError_InvalidNextToken,                    @"InvalidNextToken"                     },
    { eASDPrAPIError_InvalidNumberPredicated,             @"InvalidNumberPredicated"              },
    { eASDPrAPIError_InvalidNumberValueTests,             @"InvalidNumberValueTests"              },
    { eASDPrAPIError_InvalidParameterCombination,         @"InvalidParameterCombination"          },
    { eASDPrAPIError_InvalidParameterValue,               @"InvalidParameterValue"                },
    { eASDPrAPIError_InvalidQueryExpression,              @"InvalidQueryExpression"               },
    { eASDPrAPIError_InvalidResponseGroups,               @"InvalidResponseGroups"                },
    { eASDPrAPIError_InvalidService,                      @"InvalidService"                       },
    { eASDPrAPIError_InvalidSortExpression,               @"InvalidSortExpression"                },
    { eASDPrAPIError_InvalidURI,                          @"InvalidURI"                           },
    { eASDPrAPIError_MissingAction,                       @"MissingAction"                        },
    { eASDPrAPIError_MissingParameter,                    @"MissingParameter"                     },
    { eASDPrAPIError_MultipleExistsConditions,            @"MultipleExistsConditions"             },
    { eASDPrAPIError_MultipleExistsNames,                 @"MultipleExistsNames"                  },
    { eASDPrAPIError_MultipleExistsValues,                @"MultipleExistsValues"                 },
    { eASDPrAPIError_MultiValuesAttribute,                @"MultiValuesAttribute"                 },
    { eASDPrAPIError_NoSuchDomain,                        @"NoSuchDomain"                         },
    { eASDPrAPIError_NotYetImplemented,                   @"NotYetImplemented"                    },
    { eASDPrAPIError_NumberDomainsExceeded,               @"NumberDomainsExceeded"                },
    { eASDPrAPIError_NumberDomainAttributesExceeded,      @"NumberDomainAttributesExceeded"       },
    { eASDPrAPIError_NumberItemsAttributesExceeded,       @"NumberItemsAttributesExceeded"        },
    { eASDPrAPIError_NumberSubmittedAttributesExceeded,   @"NumberSubmittedAttributesExceeded"    },
    { eASDPrAPIError_RequestExpired,                      @"RequestExpired"                       },
    { eASDPrAPIError_RequestTimeout,                      @"RequestTimeout"                       },
    { eASDPrAPIError_ServiceUnavailable,                  @"ServiceUnavailable"                   },
    { eASDPrAPIError_TooManyRequestedAttributes,          @"TooManyRequestedAttributes"           },
    { eASDPrAPIError_UnsupportedHttpVerb,                 @"UnsupportedHttpVerb"                  },
    { eASDPrAPIError_UnsuppotedNextToken,                 @"UnsuppotedNextToken"                  },
    { eASDPrAPIError_URITooLong,                          @"URITooLong"                           },
};

ASDPrElementDictionary *gASDPrDef_dictionaryBase                = nil;
ASDPrElementDictionary *gASDPrDef_dictionaryCreateDomain        = nil;
ASDPrElementDictionary *gASDPrDef_dictionaryDeleteDomain        = nil;
ASDPrElementDictionary *gASDPrDef_dictionaryDomainMetadata      = nil;
ASDPrElementDictionary *gASDPrDef_dictionaryListDomains         = nil;
ASDPrElementDictionary *gASDPrDef_dictionaryGetSelect           = nil;
ASDPrElementDictionary *gASDPrDef_dictionaryAPIErrors           = nil;

@implementation ASDPrDef
- (id)          init {
    return nil;     // Static methods only, class can not be instanced
}
+ (ASDPrElementDictionary*)     dictionaryBase {
    if ( gASDPrDef_dictionaryBase == nil ) {
        @synchronized( self ) {
            if ( gASDPrDef_dictionaryBase == nil ) {
                NSMutableArray *elements = [[ASDPrElementDictionary elementArrayFromStruct: &astASDPrElementBase[0] 
                                                                                     Count: mASDarrayCount( astASDPrElementBase )] retain];
                gASDPrDef_dictionaryBase = [[ASDPrElementDictionary alloc] initWithElements: elements];
                [elements release];
            }
        }
    }
    return gASDPrDef_dictionaryBase;
}
+ (ASDPrElementDictionary*)     dictionaryBatchPutAttributes {
    return [self dictionaryBase];
}
+ (ASDPrElementDictionary*)     dictionaryCreateDomain {
    if ( gASDPrDef_dictionaryCreateDomain == nil ) {
        ASDPrElementDictionary *dictBase = [[self dictionaryBase] retain];
        @synchronized( self ) {
            if ( gASDPrDef_dictionaryCreateDomain == nil ) {
                NSMutableArray *elements = [[ASDPrElementDictionary elementArrayFromStruct: &astASDPrElementCreateDomain[0] 
                                                                                     Count: mASDarrayCount( astASDPrElementCreateDomain )] retain];
                gASDPrDef_dictionaryCreateDomain = [[ASDPrElementDictionary alloc] initWithDictionary: dictBase Elements: elements];
                [elements release];
            }
        }
        [dictBase release];
    }
    return gASDPrDef_dictionaryCreateDomain;
}
+ (ASDPrElementDictionary*)     dictionaryDeleteAttributes {
    return [self dictionaryBase];
}
+ (ASDPrElementDictionary*)     dictionaryDeleteDomain {
    if ( gASDPrDef_dictionaryDeleteDomain == nil ) {
        ASDPrElementDictionary *dictBase = [[self dictionaryBase] retain];
        @synchronized( self ) {
            if ( gASDPrDef_dictionaryDeleteDomain == nil ) {
                NSMutableArray *elements = [[ASDPrElementDictionary elementArrayFromStruct: &astASDPrElementDeleteDomain[0] 
                                                                                     Count: mASDarrayCount( astASDPrElementDeleteDomain )] retain];
                gASDPrDef_dictionaryDeleteDomain = [[ASDPrElementDictionary alloc] initWithDictionary: dictBase Elements: elements];
                [elements release];
            }
        }
        [dictBase release];
    }
    return gASDPrDef_dictionaryDeleteDomain;
}
+ (ASDPrElementDictionary*)     dictionaryDomainMetadata {
    if ( gASDPrDef_dictionaryDomainMetadata == nil ) {
        ASDPrElementDictionary *dictBase = [[self dictionaryBase] retain];
        @synchronized( self ) {
            if ( gASDPrDef_dictionaryDomainMetadata == nil ) {
                NSMutableArray *elements = [[ASDPrElementDictionary elementArrayFromStruct: &astASDPrElementDomainMetadata[0] 
                                                                                     Count: mASDarrayCount( astASDPrElementDomainMetadata )] retain];
                gASDPrDef_dictionaryDomainMetadata = [[ASDPrElementDictionary alloc] initWithDictionary: dictBase Elements: elements];
                [elements release];
            }
        }
        [dictBase release];
    }
    return gASDPrDef_dictionaryDomainMetadata;
}
+ (ASDPrElementDictionary*)     dictionaryListDomains {
    if ( gASDPrDef_dictionaryListDomains == nil ) {
        ASDPrElementDictionary *dictBase = [[self dictionaryBase] retain];
        @synchronized( self ) {
            if ( gASDPrDef_dictionaryListDomains == nil ) {
                NSMutableArray *elements = [[ASDPrElementDictionary elementArrayFromStruct: &astASDPrElementListDomains[0] 
                                                                                     Count: mASDarrayCount( astASDPrElementListDomains )] retain];
                gASDPrDef_dictionaryListDomains = [[ASDPrElementDictionary alloc] initWithDictionary: dictBase Elements: elements];
                [elements release];
            }
        }
        [dictBase release];
    }
    return gASDPrDef_dictionaryListDomains;
}
+ (ASDPrElementDictionary*)     dictionaryPutAttributes {
    return [self dictionaryBase];
}
+ (ASDPrElementDictionary*)     dictionaryGetSelect {
    if ( gASDPrDef_dictionaryGetSelect == nil ) {
        ASDPrElementDictionary *dictBase = [[self dictionaryBase] retain];
        @synchronized( self ) {
            if ( gASDPrDef_dictionaryGetSelect == nil ) {
                NSMutableArray *elements = [[ASDPrElementDictionary elementArrayFromStruct: &astASDPrElementGetSelect[0] 
                                                                                     Count: mASDarrayCount( astASDPrElementGetSelect )] retain];
                gASDPrDef_dictionaryGetSelect = [[ASDPrElementDictionary alloc] initWithDictionary: dictBase Elements: elements];
                [elements release];
            }
        }
        [dictBase release];
    }
    return gASDPrDef_dictionaryGetSelect;
}
+ (ASDPrElementDictionary*)     dictionaryAPIErrors {
    if ( gASDPrDef_dictionaryAPIErrors == nil ) {
        @synchronized( self ) {
            if ( gASDPrDef_dictionaryAPIErrors == nil ) {
                NSMutableArray *elements = [[ASDPrElementDictionary elementArrayFromStruct: &astASDPrAPIError[0] 
                                                                                     Count: mASDarrayCount( astASDPrAPIError )] retain];
                gASDPrDef_dictionaryAPIErrors = [[ASDPrElementDictionary alloc] initWithElements: elements];
                [elements release];
            }
        }
    }
    return gASDPrDef_dictionaryAPIErrors;
}
@end
